﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.SessionState;



namespace Gpsys.Web.Common
{
    public class UserHelpers
    {
        private static HttpSessionState Session
        {
            get
            {
                return HttpContext.Current.Session;
            }
        }

        private static string GetStringFromSession(string key)
        {
            //var c = EndpointHost.AppHost.TryResolve<ICacheClient>();
            var obj = Session[key];
            if (obj != null)
                return obj.ToString();

            return string.Empty;
        }

        private static void SetToSession(string key, object value)
        {
            Session[key] = value;
        }

        /// <summary>
        /// Gets or sets the name of the user.
        /// </summary>
        /// <value>
        /// The name of the user.
        /// </value>
        public static string UserName
        {
            get
            {
                return GetStringFromSession("UserName");
            }

            set
            {
                SetToSession("UserName", value);
            }
        }

        public static string Name
        {
            get
            {
                return GetStringFromSession("Name");
            }

            set
            {
                SetToSession("Name", value);
            }
        }
    }
}